import math


class Graphic:
    def __init__(self, name):
        self.name = name

    def area(self):
        raise NotImplemented


class Rectangle(Graphic):
    def __init__(self, width, height):
        self.width = width
        self.height = height
        super().__init__("矩形")

    def area(self):
        return self.width * self.height


class Circle(Graphic):
    def __init__(self, radius):
        self.radius = radius
        super().__init__("圆")

    def area(self):
        return math.pi * self.radius ** 2


class GraphicManager:
    def __init__(self):
        self.__graphics = []

    def add_graphic(self, g):
        if not isinstance(g, Graphic):
            return
        self.__graphics.append(g)

    def cal_area(self):
        for item in self.__graphics:
            if isinstance(item, Graphic):
                print(item.name + "的面积" + str(item.area()))


graphicManager = GraphicManager()
graphicManager.add_graphic(Rectangle(20, 20))
graphicManager.add_graphic(Circle(1))
graphicManager.cal_area()
